// var url = document.location.toString()
// url = url.replace(/%EF%BC%9F/g, '?')
import * as utils from './utils'

var catid = utils.getUrlString('catid')
var tfrom = utils.getUrlString('tfrom')
// 判断是否含有该参数，有则调取统计接口
if (tfrom != '' && tfrom != null && tfrom != undefined && tfrom != false) {
  // 判断是否为第一次进入，该接口只调取一次
  if (!sessionStorage.getItem('firstInThisPhpJs')) {
    sessionStorage.setItem('firstInThisPhpJs', true)
    var strArr = 'hsd,sdf,klj,jkd'.split(',')
    for (let i = 0; i < strArr.length; i++) {
      // 标识内是否包含关键字
      var signpos = tfrom.indexOf(strArr[i])
      if (signpos != -1) {
        // 标识
        var ajaxurl = 'http://39.96.196.28:8090/promote/index.php?sign=' + tfrom + '&sid=' + catid

        var ajax
        if (window.XMLHttpRequest) {
          ajax = new XMLHttpRequest()
        } else {
          ajax = new window.ActiveXObject('Microsoft.XMLHTTP')
        }
        ajax.open('GET', ajaxurl, true)
        ajax.send()
        break
      }
    }
  }
}
